{ "cells": [ { "cell_type": "markdown", "source": [ "# Exercises with Numpy arrays\n", "\n", "## Try me\n", "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ffraile/computer_science_tutorials/blob/main/source/Applied%20Mathematics/exercises/Numpy%20arrays.ipynb)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ffraile/computer_science_tutorials/main?labpath=source%2FApplied%20Mathematics%2Fexercises%2FNumpy%20arrays.ipynb)\n", "\n", "\n", "2. Use array programming to calculate the total sales revenues given the vector of sold units:\n", "```python sold_units = [15, 13, 23]``` and a the vector of prices per unit ```python prices = [10, 8, 9]```. Both vectors contain the sales and prices of the products in the same ordering by product type. " ], "metadata": { "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "markdown", "source": [ "3. Reshape the following array ```an_array = [0,1,2,3,4,5,6,7]``` into a matrix of rank 3 and equal number of elements in each dimension" ], "metadata": { "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "markdown", "source": [ "4. Check the Numpy library documentation and write a Python script to generate a multidimensional array of shape (10,10,1000) where the elements are integer numbers drawn from a discrete uniform distribution in the range [0, 100]." ], "metadata": { "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "markdown", "source": [ "5. Write a script to compute the average values of the matrix above along each dimension, using the function numpy.mean." ], "metadata": { "pycharm": { "name": "#%% md\n" } } }, { "cell_type": "markdown", "source": [ "6. Write a Python script that a) defines two arrays of shape (1000,1000) and b) defines a third array that contains the element-wise maxima of the elements in both arrays. Check the numpy.maximum documentation." ], "metadata": { "pycharm": { "name": "#%% md\n" } } } ], "metadata": { "orig_nbformat": 4, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 2 }